package org.advanced.annotation;

import java.lang.reflect.Method;

/**
 * @author John.zhang
 * @version Id: MyMain, v 1.0 2020/12/7 10:25 ZhiYong Exp $
 */

@InvokeAnn(className = "org.advanced.annotation.Student", MethodName = "show")
public class MyMain {

    public static void main(String[] args) throws Exception {
        Class<MyMain> myMainClass = MyMain.class;
        InvokeAnn annotation = myMainClass.getAnnotation(InvokeAnn.class);
        Class<?> aClass = Class.forName(annotation.className());
        Method declaredMethod = aClass.getDeclaredMethod(annotation.MethodName());
        declaredMethod.invoke(aClass.newInstance());
    }

}
